import { HttpUrlVariable } from "@/constants";
import type{ CreateOrderResult } from "@/types/consult";
import type{ Address, deleteResult, ExpressData, MedicalOrderDetail, objectListResult, orderListParams, OrderPre, OrderQueryParams, PostOrderParams } from "@/types/order";
import RequestHttp from "@/utils/request";

export const getAddressListAPI = () => RequestHttp.get<Address[]>(HttpUrlVariable.ADDRESS_LIST_URL)

export const getcomputePriceAPI = (params:OrderQueryParams) => RequestHttp.get<OrderPre,OrderQueryParams>(HttpUrlVariable.COMPUTE_PRICE_URL, params)

//预下单接口
export const preOrderAPI = (params:PostOrderParams) => RequestHttp.post<CreateOrderResult,PostOrderParams>(HttpUrlVariable.PRESCRIPTION_ORDER_PRE_URL, params)

//订单详情接口
export const getPrescriptionOrderDetailAPI = (id:string) => RequestHttp.get<MedicalOrderDetail>(HttpUrlVariable.PRESCRIPTION_ORDER_DETAIL_URL + id)

// 删除订单
export const deleteOrderAPI = (id:string) => RequestHttp.delete<deleteResult>(HttpUrlVariable.DELETE_ORDER_URL + id)

// 订单列表
export const getOrderListAPI = (params:orderListParams) => RequestHttp.get<objectListResult,orderListParams>(HttpUrlVariable.ORDER_LIST_URL, params)

// 查询物流详情
export const getPrescriptionOrderLogisticsAPI = (id: string) =>
    RequestHttp.get<ExpressData>(`/patient/order/${id}/logistics`)

